package com.dmtt.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMqConfig {
    //1.申明注册fanout模式的交换机
    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange("direct_order_exchange",true,false);
    }
    //2.声明队列 sms.direct.queue
    @Bean
    public Queue yujingQueue(){
        return new Queue("yujing",true);
    }
    @Bean
    public Queue jingbaoQueue(){
        return new Queue("jingbao",true);
    }
    //3.完成绑定关系（队列和交换机完成绑定关系）
    @Bean
    public Binding yujingBingding(){
        return BindingBuilder.bind((yujingQueue())).to(directExchange()).with("yujing");
    }
    @Bean
    public Binding jingbaoBingding(){
        return BindingBuilder.bind((jingbaoQueue())).to(directExchange()).with("jingbao");
    }
}
